 $(function(){
	
	easyloader.base = '../../js/tools/locale/';
    easyloader.load('easyui-lang-zh_CN.js', function(){     
	    var pram={email:'',currentPage:1,startDate:"",endDate:""};
		
         $("#dataGrid").datagrid({
				        height: 450,
						width:1140,
                        pagination: true,
						rownumbers:true,
						striped:true,
						pageList:[15,20,25,30],
						pageSize:15,
						showPageList:true,
						singleSelect:true,
						queryParams:pram,
                        url: '../../groupbyajax/user!userList.action',
                        columns: [[
						          {field: 'email',title: '用户标识',width: 150,align: 'left'},
						          {field: 'level',title: '用户类型',width: 80,align: 'center'},
						          {field: 'registerTime',title: '注册时间',width: 120,align: 'left'}, 
								  {field: 'recommend',title: '推荐',width:120,align: 'center'}
							 ]]
			        });		 
			});	
			
	  
});	
function addButton()
{
	
var pager = $('#dataGrid').datagrid('getPager');   
					pager.pagination({
						pageList:[15,20,25,30],
						pageSize:15,
						showPageList:true,
						buttons:[{
							iconCls:'icon-print',
							handler:function(){
								doPrint();
							}
						}]
					});
}
function recommend(userId,flag)
{
	var date =new Date();
	$.getJSON("../../groupbyajax/user!recommendUser.action?times="+date.getTime(),{userId:userId,flag:flag},function(data){
		if(data.success)
		{
             if(flag==0)
			{
				$("#u"+userId).parent().html("<a href='javascript:void(0)' onclick='recommend("+userId+",1,this);' id='u"+userId+"'><font color='blue'>推荐</color></font></a>");
			}else
			{
				$("#u"+userId).parent().html("<a href='javascript:void(0)' onclick='recommend("+userId+",0,this);' id='u"+userId+"'><font color='red'>取消推荐</color></font>");
			}

		}
	});
}
function delUser(id)
{
	$.getJSON("../../groupbyajax/user!deleteUser.action",{id:id},function(data){
		if(data.success)
		{
			$("#dataGrid").datagrid('reload');
		}
	})
}
function search()
{
	var name=$("#name").val();
	var startdate=$("#startdate").val();
	var enddate=$("#enddate").val();
	var categoryId=$("#categoryId").val();
	$('#dataGrid').datagrid({
				  striped: true,
				  queryParams:{email:name,startTime:startdate,endTime:enddate,categoryId:categoryId}
			   });
}
